﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Net;

namespace WeFeTeLib.CakePHP
{
    class CakePHPFramework : Framework
    {
        public CakePHPFramework()
            : base()
        {
            name = "CakePHP";
        }

        public override void setDefaultFiles()
        {
            frameworkFiles = new List<File>();

            /* This file can have two responses: 
             * - The debug level is set to 0 (the expected) and the "Debug settings..." text appears
             * - The debug level is >0 so we can see all the debug messages */
            frameworkFiles.Add(new File("test.php", 
                                        "Debug setting does not allow access to this url.", 
                                        HttpStatusCode.OK));
            
            /* The css.php use to serve the "File Not Found" text */
            frameworkFiles.Add(new File("css.php",
                                        "File Not Found",
                                        HttpStatusCode.NotFound));

            /* If not file parameter of invalid file parameter is passed, the page return a 404 code */
            frameworkFiles.Add(new File("js/vendors.php",
                                        0,
                                        HttpStatusCode.NotFound));

            /* This is a default css file and if the webmaster doesn't delete it, you can detect a CakePHP */
            frameworkFiles.Add(new File("css/cake.generic.css",
                                        "/* General Style Info */", 
                                        HttpStatusCode.OK));

            /* A default image file */
            frameworkFiles.Add(new File("img/cake.power.gif", 
                                        201, 
                                        HttpStatusCode.OK));

            /* A default image file */
            frameworkFiles.Add(new File("img/cake.icon.gif", 
                                        233, 
                                        HttpStatusCode.OK));
        }

        public override void setDefaultCookies()
        {
            frameworkCookies = new List<Cookie>();

            /* The default CakePHP cookie is named CAKEPHP and has 26 chars length */
            frameworkCookies.Add(new Cookie("CAKEPHP", 
                                            26));
        }

        public override void setDefaultFolders()
        {
            frameworkFolders = new List<Folder>();

            /* The default CakePHP .htaccess file redirects the http://domain.com/css to
             * http://domain.com/css/ with a Moved Permanently HTTP Status Code */
            frameworkFolders.Add(new Folder("css", HttpStatusCode.MovedPermanently));
        }

        public override void setDefaultHeaders()
        {
        }
    }
}
